package com.sdy.hospitalguard.embed.mq.config;

import com.sdy.hospitalguard.biz.constants.MqConstants;
import com.sdy.hospitalguard.embed.mq.consumer.ServerConsumer;
import com.sdy.mq.base.BaseOrderedMessageListener;
import com.sdy.mq.config.RocketMqConfig;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * 消费
 * </p>
 *
 * @author fb
 * @since 2020/5/8
 */
@Configuration
public class ConsumerGroupConfig {

    @Autowired
    private RocketMqConfig rocketMqConfig;
    @Autowired
    private ServerConsumer serverConsumer;

    @Bean
    public DefaultMQPushConsumer embedServerListener() throws Exception {
        return rocketMqConfig.createConsumerGroup("consumer_group_hospital_guard_server",
                new BaseOrderedMessageListener(serverConsumer), MqConstants.Topics.TOPIC_HOSPITAL_GUARD,
                "tag_embed_server || tag_access_add || tag_access_delete", 1, 1);
    }

}
